home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / driverss.zip / AT&T.ASM < prev    next >
Assembly Source File  |  1991-01-26  |  7KB  |  280 lines

  1. version    equ    1
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210, by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;Updated to version 1.08 Feb. 17, 1989 by Russell Nelson.
  9. ;Updated to support 1500 byte MTU April 27, 1989 By Brad Clements.
  10. ;converted to an AT&T driver Feb 16, 1990 by Russell Nelson
  11.  
  12. ;  Copyright, 1988, 1989, 1990, Russell Nelson
  13.  
  14. ;   This program is free software; you can redistribute it and/or modify
  15. ;   it under the terms of the GNU General Public License as published by
  16. ;   the Free Software Foundation, version 1.
  17. ;
  18. ;   This program is distributed in the hope that it will be useful,
  19. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;   GNU General Public License for more details.
  22. ;
  23. ;   You should have received a copy of the GNU General Public License
  24. ;   along with this program; if not, write to the Free Software
  25. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. code    segment    word public
  28.     assume    cs:code, ds:code
  29.  
  30. ;
  31. ;  Equates for controlling the AT&T boards
  32. ;
  33. ;  I/O addresses, writing anything in AL trips these gates
  34. ;
  35. ;  First six addresses are the EPROM board Ether address (read)
  36. ;
  37. IORESET    EQU    0            ; reset the board
  38. IOCA    EQU    1            ; Channel Attention
  39. IOREV    EQU    6            ; Board Revision/Type
  40. IOATTR    EQU    7            ; Attribute Register.
  41.  
  42. ;Attribute register contents:
  43. attr_mem    equ    03h        ;mask for memory size
  44. attr_mem_64    equ    0
  45. attr_mem_16    equ    1
  46. attr_mem_32    equ    2
  47. attr_mem_8    equ    3
  48. ;
  49. attr_bw        equ    04h        ;Bus width (0=8 bit, 1=16 bit)
  50. attr_speed    equ    08h        ;Board speed (0=10 Mhz, 1=1 Mhz)
  51. attr_c        equ    10h        ;Manchester code (0=Manchester, 1=NRZ)
  52. attr_hw        equ    20h        ;Host bus width (0=16, 1=8 bit)
  53. attr_es        equ    40h        ;Ethernet/Starlan (0 = E, 1 = S)
  54. attr_b        equ    80h        ;Boot Rom (0=No ROM, 1=ROM)
  55.  
  56.  
  57. ;
  58. ;  Data segment
  59. ;
  60.  
  61.     public    int_no
  62. int_no        db    2,0,0,0        ; interrupt number. 
  63. io_addr        dw    0360h,0        ; I/O address for card (jumpers)
  64. base_addr    dw      0d000h,0    ; base segment for board (jumper set)
  65.  
  66.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  67. driver_class    db    BLUEBOOK, IEEE8023, 0        ;from the packet spec
  68. driver_type    db    48        ;from the packet spec
  69. driver_name    db    20 dup(?)    ;name of the driver.
  70. driver_function    db    2
  71. parameter_list    label    byte
  72.     db    1    ;major rev of packet driver
  73.     db    9    ;minor rev of packet driver
  74.     db    14    ;length of parameter list
  75.     db    EADDR_LEN    ;length of MAC-layer address
  76.     dw    GIANT    ;MTU, including MAC headers
  77.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  78.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  79.     dw    0    ;(# of successive xmits) - 1
  80. int_num    dw    0    ;Interrupt # to hook for post-EOI
  81.             ;processing, 0 == none,
  82.  
  83. enable_network:
  84. ;  connect to network
  85.     ret
  86.  
  87.  
  88. reset_586:
  89. ;  Reset the chip
  90.     loadport
  91.     setport    IORESET
  92.     out    dx,al
  93.     ret
  94.  
  95.  
  96.     public    get_address
  97. get_address:
  98. ;get the address of the interface.
  99. ;enter with es:di -> place to get the address, cx = size of address buffer.
  100. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  101.     assume    ds:code
  102.     cmp    cx,EADDR_LEN        ;make sure that we have enough room.
  103.     jb    get_address_2
  104.     mov    cx,EADDR_LEN
  105.     mov    dx,io_addr        ; Get our IO base address.
  106.     cld
  107. get_address_1:
  108.     in    al,dx            ; get a byte of the eprom address
  109.     stosb                ; put it away
  110.     inc    dx            ; next register
  111.     loop    get_address_1        ; go back for rest
  112.     mov    cx,EADDR_LEN
  113.     clc
  114.     ret
  115. get_address_2:
  116.     stc
  117.     ret
  118.  
  119.  
  120. doca:
  121. ;we may be called from places in which ds is unknown.
  122.     assume    ds:nothing
  123.     loadport
  124.     setport    IOCA
  125.     out    dx,al            ; send it
  126.     ret
  127.     assume    ds:code
  128. ;yet, we really should assume ds==code for the rest of this stuff.
  129.  
  130. ;
  131. ; Here we include the code that is common between 82586 implementations.
  132. ; Everything above this is resident.
  133.     include    82586.asm
  134. ; Everything below this is discarded upon installation.
  135.  
  136.     public    usage_msg
  137. usage_msg    db    "usage: at&t [-n] [-d] [-w] <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  138.  
  139.     public    copyright_msg
  140. copyright_msg    db    "Packet driver for the AT&T Starlan/Ethernet boards, version ",'0'+majver,".",'0'+version,".",'0'+i82586_version,CR,LF
  141.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  142.  
  143. board_name_list    dw    board_00, board_01, board_11, board_21
  144.         dw    board_02, board_03, board_unk
  145.  
  146. board_00    db    00h, "StarLAN 1",0,47
  147. board_01    db    01h, "StarLAN 10 NAU",0,48
  148. board_11    db    11h, "StarLAN 10 R2 NAU",0,48
  149. board_21        db      21h, "Starlan 10 R3 NAU",0,48           ; new board
  150. board_02    db    02h, "EN100",0,49
  151. board_03    db    03h, "StarLAN Fiber NAU",0,55
  152. board_unk    db    -1h, "Unknown AT&T",0,48        ;just a guess.
  153.  
  154.     extrn    chrout: near
  155.  
  156. check_board:
  157.     assume    ds:code
  158.     loadport
  159.     setport    IOREV
  160.     in    al,dx
  161.     mov    bx,offset board_name_list
  162. check_board_name:
  163.     mov    si,[bx]            ;get a pointer to a string.
  164.     add    bx,2
  165.     cmp    byte ptr [si],-1    ;is this the end?
  166.     je    check_board_found
  167.     cmp    al,[si]            ;is this the right one?
  168.     jne    check_board_name
  169. check_board_found:
  170.     inc    si            ;skip the board revision number.
  171.  
  172.     mov    dx,offset this_board_msg
  173.     mov    ah,9
  174.     int    21h
  175.  
  176.     mov    ax,ds            ;copy the driver name to where
  177.     mov    es,ax            ;  we need it.
  178.     mov    di,offset driver_name
  179. check_board_copy:
  180.     lodsb
  181.     stosb
  182.     or    al,al
  183.     je    check_board_done_print
  184.     call    chrout            ;print the character.
  185.     jmp    check_board_copy
  186. check_board_done_print:
  187.     lodsb                ;copy the driver type number over
  188.     mov    driver_type,al
  189.     mov    al,CR
  190.     call    chrout
  191.     mov    al,LF
  192.     call    chrout
  193.  
  194.     loadport
  195.     setport    IOATTR
  196.     in    al,dx            ;get the bus width bit into bit zero.
  197.     shr    al,1
  198.     shr    al,1
  199.     not    al
  200.     and    al,1            ;and negate it.
  201.     mov    SCP,al            ;that makes it into the bus width flag.
  202.  
  203.     in    al,dx            ;get the manchester code
  204.     shr    al,1
  205.     shr    al,1
  206.     not    al            ;the bit is flipped.
  207.     and    al,4            ;isolate just the manchester/~nrz bit.
  208.     mov    byte ptr CBCONF_FLAGS,al
  209.  
  210.     mov    dx,io_addr    ; i/o address
  211.     in    al,dx
  212.     mov    bl,al        ; assemble pattern to check
  213.     inc    dx
  214.     in    al,dx
  215.     mov    bh,al
  216.     cmp    bx,0008h    ; pattern known to be there in ROM
  217.     jz    have_att_io
  218.     pop    dx            ;drop our return address
  219.     mov    dx,offset no_att_io_msg
  220.     jmp    error
  221. have_att_io:
  222.  
  223.     mov    ax,base_addr
  224.     mov    cx,2000h        ;test only what we are going to use.
  225.     call    memory_test
  226.     jz    have_att_mem
  227.     pop    dx            ;drop our return address
  228.     mov    dx,offset no_att_mem_msg
  229.     jmp    error
  230. have_att_mem:
  231.     ret
  232.  
  233.  
  234. this_board_msg    db    "This board is an AT&T ",'$'
  235. no_att_io_msg    db    "No AT&T board found at that I/O address.",CR,LF,'$'
  236. no_att_mem_msg    db    "No AT&T board found at that memory address.",CR,LF,'$'
  237.  
  238.     public    parse_args
  239. parse_args:
  240.     mov    di,offset int_no
  241.     call    get_number
  242.     mov    di,offset io_addr
  243.     call    get_number
  244.     mov    di,offset base_addr
  245.     call    get_number
  246.     clc
  247.     ret
  248.  
  249.  
  250. int_no_name    db    "Interrupt number ",'$'
  251. io_addr_name    db    "I/O port ",'$'
  252. base_addr_name    db    "Memory address ",'$'
  253.  
  254.  
  255.     public    print_parameters
  256. print_parameters:
  257.     mov    di,offset int_no
  258.     mov    dx,offset int_no_name
  259.     call    print_number
  260.     mov    di,offset io_addr
  261.     mov    dx,offset io_addr_name
  262.     call    print_number
  263.     mov    ax,memory_begin
  264.     mov    cl,4
  265.     shr    ax,cl
  266.     add    base_addr,ax
  267.     push    ax
  268.     mov    di,offset base_addr
  269.     mov    dx,offset base_addr_name
  270.     call    print_number
  271.     pop    ax
  272.     sub    base_addr,ax
  273.     ret
  274.  
  275.     include    memtest.asm
  276.  
  277. code    ends
  278.  
  279.     end
  280.